const router = require('koa-router')()

const UserController = require('../controllers/user');
const ArticleController = require('../controllers/Article')

router.get('/', async (ctx, next) => {
  await ctx.render('index', {
    title: 'Hello Koa 2!'
  })
})

// 用户
router.post('/user/register', UserController.create);
router.post('/user/login', UserController.login);
router.get('/user/info', UserController.getUser);
router.get('/user/list', UserController.getUserList);


// 文章
router.get('/article/list', ArticleController.list)
router.get('/article/detail/:id', ArticleController.detail);
router.post('/article/create', ArticleController.create);
router.put('/article/update/:id', ArticleController.update);


module.exports = router
